Return to start page

Systems/Gui/Struct Image.j

Code

		
1			library AStructSystemsGuiImage requires ALibraryCoreInterfaceImage, AStructSystemsGuiWidget
2
3 /// Uses the default Jass type @type image to treat images in GUIs.
4 struct AImage extends AWidget
5 //dynamic members
6 private string m_file
7 private integer m_red
8 private integer m_green
9 private integer m_blue
10 private integer m_alpha
11 //members
12 private image m_image
13
14 //dynamic members
15
16 public method setFile takes string file returns nothing
17 set this.m_file = file
18 if (this.m_image != null) then //file is not dynamic :-(
19 call DestroyImage(this.m_image)
20 set this.m_image = null
21 endif
22 set this.m_image = CreateImageForPlayer(this.user(), file, this.mainWindow().getX(this.x()), this.mainWindow().getY(this.y()), 5.0, this.sizeX(), this.sizeY()) //0.0 instead of 5.0
23 call ShowImage(this.m_image, this.isShown())
24 endmethod
25
26 public method file takes nothing returns string
27 return this.m_file
28 endmethod
29
30 public method setColour takes integer red, integer green, integer blue, integer alpha returns nothing
31 set this.m_red = red
32 set this.m_green = green
33 set this.m_blue = blue
34 set this.m_alpha = alpha
35 call SetImageColor(this.m_image, red, green, blue, alpha)
36 endmethod
37
38 public method red takes nothing returns integer
39 return this.m_red
40 endmethod
41
42 public method green takes nothing returns integer
43 return this.m_green
44 endmethod
45
46 public method blue takes nothing returns integer
47 return this.m_blue
48 endmethod
49
50 public method alpha takes nothing returns integer
51 return this.m_alpha
52 endmethod
53
54 //methods
55
56 public stub method show takes nothing returns nothing
57 call super.show()
58 if (this.m_image != null) then
59 call ShowImage(this.m_image, true)
60 endif
61 endmethod
62
63 public stub method hide takes nothing returns nothing
64 call super.hide()
65 if (this.m_image != null) then
66 call ShowImage(this.m_image, false)
67 endif
68 endmethod
69
70 public static method create takes AMainWindow mainWindow, real x, real y, real sizeX, real sizeY, AWidgetOnHitAction onHitAction, AWidgetOnTrackAction onTrackAction returns AImage
71 local AImage this = AImage.allocate(mainWindow, x, y, sizeX, sizeY, onHitAction, onTrackAction)
72 //members
73 set this.m_image = null
74
75 return this
76 endmethod
77
78 public method onDestroy takes nothing returns nothing
79 if (this.m_image != null) then
80 call DestroyImage(this.m_image)
81 set this.m_image = null
82 endif
83 endmethod
84 endstruct
85
86 endlibrary